﻿# CMakeList.txt: mqttTest 的 CMake 项目，在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required (VERSION 3.8)

# 如果支持，请为 MSVC 编译器启用热重载。
if (POLICY CMP0141)
  cmake_policy(SET CMP0141 NEW)
  set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)

project ("NetWorkLearn")

# 设置静态库导出路径
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
# 设置动态库导出路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
# 设置可执行文件导出路径
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

# note: 添加boost库的两种方法：
#		1、在find_package之前，
#				使用list(APPEND CMAKE_MODULE_PATH [PATH]) 的方式加入Boost的cmake目录路径
#				使用list(APPEND CMAKE_PREFIX_PATH [PATH]) 的方式加入Boost的cmake目录路径
#		2、在find_package时，使用PATHS "C:\\Users\\Jyang\\Desktop\\cppProjs\\boost_1_86_0\\boost_1_86_0\\stage\\lib\\cmake"

# find_package：https://cmake.org/cmake/help/latest/command/find_package.html#search-procedure
# CMAKE_MODULE_PATH 用于指定查找模块文件（如 FindBoost.cmake）的路径。对应find_package的 Module mode
list(APPEND CMAKE_MODULE_PATH "C:/Users/Jyang/Desktop/cppProjs/boost_1_86_0/boost_1_86_0/stage/lib/cmake")
# CMAKE_PREFIX_PATH 用于指定查找库和头文件（如 BoostConfig.cmake）的路径。对应find_package的 Config mode
list(APPEND CMAKE_PREFIX_PATH  "C:/Users/Jyang/Desktop/cppProjs/boost_1_86_0/boost_1_86_0/stage/lib/cmake")
message(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
find_package(Boost 1.86.0 
			#CONFIG
			#PATHS "C:\\Users\\Jyang\\Desktop\\cppProjs\\boost_1_86_0\\boost_1_86_0\\stage\\lib\\cmake"
			REQUIRED COMPONENTS filesystem)
if(Boost_FOUND)
	message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
	message(STATUS "Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
endif()


# 三方库，在3rd目录中先使用add_subdirectory生成三方库的cmake文件夹
#	再将cmake文件夹添加入module_path和prefix_path中(不可以，实测没build之前，cmake文件夹的config文件不会生成，导致find失败)
set(3rd ${CMAKE_SOURCE_DIR}/3rd)
add_subdirectory("./3rd")

# PahoMqttCpp
#list(APPEND  CMAKE_MODULE_PATH "${3rd}/paho.mqtt.cpp/build/cmake")
#list(APPEND CMAKE_PREFIX_PATH  "${3rd}/paho.mqtt.cpp/build/cmake")
#find_package(PahoMqttCpp REQUIRED paho-mqttpp3)
#if(PahoMqttCpp_FOUND)
#	message(STATUS "PahoMqttCpp_FOUND: ${PahoMqttCpp_FOUND}")
#	message(STATUS "PahoMqttCpp_SOURCE_DIR: ${PahoMqttCpp_SOURCE_DIR}")
#endif()

# 源码
add_subdirectory("./src")
